import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/components/Home/Index'
import Login from '@/components/Login/Login'
import TaskList from '@/components/Home/TaskList'
import PatientList from '@/components/Home/PatientList'
Vue.use(Router)
import store from '../store/store.js';
export default new Router({
  routes: [{
      path: '/Index',
      name: 'Index',
      component: Index,
      children:[
        {
          path:'PatientList',
          name:'PatientList',
          component:PatientList
        },
        {
          path:'TaskList',
          name:'TaskList',
          component:TaskList
        },
        
      ],
      beforeEnter: (to, from, next) => {
        if(from.name!='Login'||store.state.userInfo.userName=="")
        {
          next({name:'Login'})
        }else{
          next();
        }
      }
    },
    {
      path: '/',
      name: 'Login',
      component: Login
    }
  ]
})
